/*程序需要传进来的值*/
var gamer = new Array();
var pai,banker;
var A={
	action:undefined,/*当前出牌的玩家*/
	setInterHandle:new Array(),/*记录当前倒计时setInterval的handle*/
	setTimeHandle:new Array(),/*记录当前进程中setTimeout的handle*/
	init:function(nums){
		window._test = false; /*测试模式开关*/
		window._mark = 0; /*游戏运行局数*/
		window._nums = nums; /*玩家数*/
		window.banker = undefined; /*当前庄家*/
		window.result = new Array(); /*记录每局胜利者id*/
		banker=window.banker?window.banker:_getRandom(nums);
		this.start();
	},
	start:function(){/*游戏开始入口*/
		this.runReport();
		A=this.valueOf();
		base=B.init();
		pai = P.init();
		this.action = banker;
		for(var i=0;i<window._nums;i++){
			gamer[i] = G.init({'id':i,'pai':pai.outNumsPai(5),'name':parent.GAMER_LIST_INFO[i].name,'image':parent.GAMER_LIST_INFO[i].image})
			if(0==i){
				this.initButton()
			}else{
				$('div#gamer_'+i).append('<div class="left image_'+i+'"><div><img src="'+gamer[i].image+'" width="60" height="60"></div><div class="left name"><span>'+gamer[i].name+'</span></div></div>')	
			}
			$('div#gamer_'+i).append('<div id="gamer_paiarea_'+i+'"></div>')
			$('#publicarea').append('<div class="time time_'+i+'"></div>')
			$('#publicarea').append('<div class="outpaiarea outpaiarea_'+i+'"></div>')
			$('div.resultarea').append('<div class="content"><table border=0 cellpadding=0 width="100%"><tr><td align="left" width="60px"><div class="gamer_name"><span title="'+gamer[i].name+'">'+gamer[i].name+'</span></div></td><td class="result_'+i+'" width="40px"><div class="bloor_border"><div class="bloor_padding result_'+i+'"></div></div></td><td align="left"><strong id="lastlife_'+i+'">13</strong></td></tr></table></div>')
		}
		this.autoRepair();
	},
	autoRepair:function(){
		this.setTimeNull()
		pai.presentPai = []
		for(var i=0;i<window._nums;i++){//补齐各存活玩家手中的牌
			if(gamer[i].life<1){
				continue;
			}
			var len = 5-gamer[i].pai.length
			var opai = pai.outNumsPai(len)
			gamer[i].deal(opai)
			gamer[i].init()
			$('#gamer_paiarea_'+i).empty()
		}
		//console.log(gamer[this.action].pai,pai.valToPai(gamer[this.action].pai));
		$('.outpaiarea').empty()
		this.showPai();
		banker = this.action
		this.main();
	},
	main:function(){
		if(window._test || gamer[this.action].automode){
			this.autoPai();
		}else{
			this.setThisTime('<strong>15</strong>')
			if(gamer[this.action].pai.length<1){
				this.autoRepair();
			}else{
				if(0==this.action){
					$('#action_gamer').show()
				}else{
					var o = this
					function m(){
						o.autoPai();
					}
					this.setTimeHandle.push(setTimeout(m,2000));	
				}
			}
		}
	},
	showPai:function(){/*页面显示*/
		for(var i=0;i<gamer.length;i++){
			for(var j=0;j<gamer[i].pai.length;j++){
				var index = gamer[i].pai[j]%13
				if(gamer[i].pai[j]/13>=4){
					index+=13
				}
				if(0==i){
					var huase='';
					if(pai.getPaiHuase(gamer[i].pai[j])<4){
						huase = '<div class="left paise_float"><img width="30px" height="30px" src="static/images/pai_'+pai.getPaiHuase(gamer[i].pai[j])+'.png"></div>'
					}
					$('#gamer_paiarea_'+i).append('<div class="showPai pai_'+i+'" val="'+gamer[i].pai[j]+'" pval="'+index+'">'+show_pai[index]+huase+'</div>')
				}else{
					$('#gamer_paiarea_'+i).append('<div class="hidePai pai_'+i+'"></div>')
				}
			}
		}	
		this.bindPai();
	},
	bindPai:function(){/*绑定玩家手牌特效*/
		var t = this;
		$('div.pai_0').click(function(){
			$(this).toggleClass('selected')
			if(this.className.search('selected')!=-1){
				t.selectPai(this);
			}else{
				t.unselectPai(this);
			}
		})
	},
	selectPai:function(t){/*玩家自主选牌动作*/
		var proto_pai = parseInt($(t).attr('val'))
		gamer[0].select.push(proto_pai)
	},
	unselectPai:function(t){/*玩家自主去选牌动作*/
		var proto_pai = parseInt($(t).attr('val'))
		var index = gamer[0].select.indexOf(proto_pai)
		if(index!=-1)
			gamer[0].select.splice(index,1)
	},
	clickOutPai:function(){/*出牌动作*/
		if(0==this.action){
			if(gamer[0].select.length>0){
				gamer[0].lastout = gamer[0].select
				gamer[0].paival = pai.valToPai(gamer[0].lastout)
			}
			this.outPai();
		}
	},
	outPai:function(){/*出牌动作*/
		if(this.checkpai()){
			this.initPrev();
			this.deskshow()
			this.checkThisPai();
		}else{
			this.alert('牌选择有误');
		}
	},
	attack:function(){/*玩家打出攻击牌*/
		if(pai.gamer[this.action].lastout[0]){}s
	},
	initPrev:function(){
		gamer[this.prev()].lastout=[]
		gamer[this.prev()].paival=[]
		gamer[this.action].select = []
		this.setThisTime('')
		gamer[this.next()].prevgamer = this.action
	},
	setAllPrev:function(){
		for(var i=0;i<window._nums;i++){
			gamer[i].prevgamer = this.action
		}
	},
	drop:function(){/*放弃动作*/
		gamer[this.action].lastout = []
		gamer[this.action].paival = []
		if(0==this.action){
			gamer[this.action].select=[]
			$('div.pai_0').removeClass('selected')
		}
		this.setThisTime('<b>不出<b>')
		this.checkThisPai();
	},
	autoPai:function(){/*电脑自动出牌*/
		if(pai.presentPai.length>0){//判断牌面是否有人已经打出牌
			var lose = gamer[this.action].lose
			if(lose){//被攻击时
				var bast = pai.getBastGuard(gamer[this.action].pai,lose)
				if(bast && bast[0][0]==undefined){debugger}
				if(!bast || bast[0].length<1 || (gamer[this.action].life>8 && lose==1 && bast[1][0]>0 && bast[1].length<2) || (gamer[this.action].life>3 && lose==1 && bast[1][0]>1 && bast[1].length<3)){//如果不存在防守牌或玩家血量大于8点且手中没有防守1点牌时作弃牌处理
					this.drop();
				}else{
					gamer[this.action].lastout = bast[0]
					gamer[this.action].paival = bast[1]
					this.outPai();
				}
			}else{//对方打出普通牌或防守牌时
				if(pai.allGuard(gamer[this.prev()].paival)){ //如果对方出防守牌 我方必须出攻击牌 否则弃牌
					var attack = pai.getAllAttack(gamer[this.action].pai) //得到手中的攻击牌
					if(!attack || attack[0].length<1 || attack[1].length<1){
						this.drop(); //此时手中无攻击牌则弃牌
					}else{
						gamer[this.action].lastout.push(attack[0][0])
						gamer[this.action].paival.push(attack[1][0])
						this.outPai();
					}
				}else{
					var outpai;
					outpai = pai.getBastAttack(gamer[this.action].pai,gamer[this.prev()].paival.length) //打出最好的攻击牌
					if(outpai){
						gamer[this.action].lastout=outpai[0]
						gamer[this.action].paival=outpai[1]
						this.outPai();
					}else{
						outpai = pai.getBastGeneral(gamer[this.action].pai,gamer[this.prev()].paival[0],gamer[this.prev()].paival.length)
						if(outpai){
							gamer[this.action].lastout=outpai[0]
							gamer[this.action].paival=outpai[1]
							this.outPai();
						}else{
							this.drop();
						}
					}
					
				}
			}
		}else{
			if(pai.allGuard(pai.valToPai(gamer[this.action].pai))){ //如果全为防守牌则本局弃牌
				this.drop()
			}else{
				var outpai = pai.getBastGeneral(gamer[this.action].pai)
				if(outpai){//有一对，三个，四条，五条类似的普通先出
					gamer[this.action].lastout=outpai[0]
					gamer[this.action].paival=outpai[1]
					this.outPai();
				}else{
					var dbp = pai.getPaivalTime([gamer[this.action].pai,pai.valToPai(gamer[this.action].pai)])
					var allattack = pai.getAllAttack(gamer[this.action].pai)
					if(allattack){
						gamer[this.action].lastout.push(allattack[0][0])
						gamer[this.action].paival.push(allattack[1][0])
						this.outPai();
					}else{
						var allgeneral = pai.getAllGeneral(gamer[this.action].pai);
						var outpai=undefined,paival=undefined;
						if(allgeneral[0]){
							for(var j=0;j<allgeneral[0].length;j++){
								var tpai = allgeneral[0][j]
								var tval = allgeneral[1][j]
								if(!dbp[tval] && outpai==undefined){
									outpai = tpai;
									paival = tval;
								}
							}
						}
						if(outpai!=undefined && paival!=undefined){
							gamer[this.action].lastout.push(outpai);
							gamer[this.action].paival.push(paival);
							this.outPai();
						}else{
							this.drop();
						}
					}
				}
			}
		}
	},
	autoAnswer:function(){/*提示功能*/
		var t = this
		if(pai.presentPai.length>0){//判断牌面是否有人已经打出牌
			var lose = gamer[t.action].lose
			if(lose){//被攻击时
				var bast = pai.getBastGuard(gamer[t.action].pai,lose)
				if(bast && bast[0][0]==undefined){debugger}
				if(!bast || bast[0].length<1){//如果不存在防守牌或玩家血量大于8点且手中没有防守1点牌时作弃牌处理
					this.drop();
				}else{
					gamer[t.action].select = bast[0]
					t.changePaiShow()
				}
			}else{//对方打出普通牌或防守牌时
				if(pai.allGuard(gamer[this.prev()].paival)){ //如果对方出防守牌 我方必须出攻击牌 否则弃牌
					var attack = pai.getAllAttack(gamer[t.action].pai) //得到手中的攻击牌
					if(!attack || attack[0].length<1 || attack[1].length<1){
						this.drop(); //此时手中无攻击牌则弃牌
					}else{
						gamer[t.action].select = attack[0]
						t.changePaiShow()
					}
				}else{
					var outpai;
					outpai = pai.getBastAttack(gamer[t.action].pai,gamer[this.prev()].paival.length) //打出最好的攻击牌
					if(outpai){
						gamer[t.action].select = outpai[0]
						t.changePaiShow()
					}else{
						outpai = pai.getBastGeneral(gamer[t.action].pai,gamer[this.prev()].paival[0],gamer[this.prev()].paival.length)
						if(outpai){
							gamer[t.action].select = outpai[0]
							t.changePaiShow()
						}else{
							this.drop();
						}
					}
					
				}
			}
		}else{
			if(pai.allGuard(pai.valToPai(gamer[t.action].pai))){ //如果全为防守牌则本局弃牌
				this.drop()
			}else{
				var outpai = pai.getBastGeneral(gamer[t.action].pai)
				if(outpai){//有一对，三个，四条，五条类似的普通先出
					gamer[t.action].select = outpai[0]
					t.changePaiShow()
				}else{
					var dbp = pai.getPaivalTime([gamer[t.action].pai,pai.valToPai(gamer[t.action].pai)])
					var allattack = pai.getAllAttack(gamer[t.action].pai)
					if(allattack){
						gamer[t.action].select=allattack[0]
						t.changePaiShow()
					}else{
						var allgeneral = pai.getAllGeneral(gamer[t.action].pai);
						var outpai=undefined,paival=undefined;
						for(var j=0;j<allgeneral[0].length;j++){
							var tpai = allgeneral[0][j]
							var tval = allgeneral[1][j]
							if(!dbp[tval] && outpai==undefined){
								outpai = tpai;
								paival = tval;
							}
						}
						if(outpai!=undefined && paival!=undefined){
							gamer[t.action].select=[outpai]
							t.changePaiShow()
						}else{
							this.drop();
						}
					}
				}
			}
		}
	},
	checkpai:function(){/*检查打出的牌是否合理*/
		var ret=true,v = gamer[this.action].paival
		var prev = this.prev()
		var prevpai = gamer[prev].lastout
		if(gamer[this.action].checkLose()){ //受到攻击 
			/*alert('牌选择有误');*/
			if(!pai.allGuard(v)){
				ret=false;
			}
		}else{ //受攻击之外
			if(!pai.allAttack(v) || prevpai.length>0){
				switch(v.length){
					case 2: if(v[0]!=v[1]){/*alert('牌选择有误');*/ret = false;};break;
					case 3: if(v[0]!=v[1]||v[0]!=v[2]||v[1]!=v[2]){/*alert('牌选择有误');*/ret = false;};break;
					case 4: if(v[0]!=v[1]||v[0]!=v[2]||v[1]!=v[2]||v[0]!=v[3]||v[1]!=v[3]||v[2]!=v[3]){/*alert('牌选择有误');*/ret = false;};break;
					case 5: if(v[0]!=v[1]||v[0]!=v[2]||v[1]!=v[2]||v[0]!=v[3]||v[1]!=v[3]||v[2]!=v[3]||v[0]!=v[4]||v[1]!=v[4]||v[2]!=v[4]||v[3]!=v[4]){/*alert('牌选择有误');*/ret = false;};break;
				}
			}
			if(prevpai.length>0){
				/*根据上家的牌来检测自己牌的正确性*/
				if(pai.allGuard(pai.valToPai(prevpai))){//对方出防守只能再出攻击牌
					if(!pai.allAttack(v)){
						ret = false;
					}			
				}else{
					if(prevpai.length != v.length || pai.haveGuard(v) || (pai.allGeneral(v)&&v[0]<=pai.valToPai(prevpai[0]))){
						ret = false;
					}
				}
			}else{/*对第一次出牌进行判断*/
				if(pai.haveGuard(v)){/*alert('牌选择有误');*/ret = false;};
			}
		}
		if(v.length<1){ret=false;}
		return ret;
	},
	checkThisPai:function(){
		//console.log(pai.valToPai(gamer[this.action].pai))
		$('#action_gamer').hide()
		this.clearAllHandle();
		var lose = gamer[this.action].checkLose();
		var restart = false;
		var o = this;
		if(lose>0){ //当前牌被攻击状态
			var flose = 0;
			if(gamer[this.action].lastout.length>0){/*得到防守牌的点数*/
				for(var i=0;i<gamer[this.action].paival.length;i++){
					flose += pai.paiToLose(gamer[this.action].paival[i])
				}
			}
			if(flose<lose){ //打出的防守点数小于被攻击点数
				gamer[this.action].life-=lose-flose;
				this.setResult(lose-flose);
				if(gamer[this.action].getLife()<1 && (window._test || !B.isOnline || this.action!=0)){//阵亡的玩家手中牌全部回归到牌堆中
					if(this.isOver()){
						//window._test || alert('恭喜您获胜，游戏将重新开始');
						banker = gamer[this.action].prevgamer
						window.result.push(gamer[banker].name)
						restart = true
					}
					this.gamerDead()
				}else if(!window._test && gamer[this.action].getLife()<1 && this.action==0){
					this.gamerDead()
					banker = gamer[this.action].prevgamer
					window.result.push(gamer[banker].name)
					//alert('您已阵亡，游戏将重新开始');
					restart = true	
				}
			}
			if(restart){
				//this.start()
				function m_over(){
					window._test?o.start():o.showOverAlert();
				}
				this.setTimeHandle.push(setTimeout(m_over,0))
			}else{
				gamer[this.action].lose=0;
				this.action = gamer[this.action].prevgamer
				//console.log(gamer[1].life,gamer[2].life,gamer[3].life)
				if(flose<lose){
					function m_repair(){
						o.autoRepair()
					}
					this.setTimeHandle.push(setTimeout(m_repair,0))
				}else{
					o.main()
				}
			}
		}else{
			gamer[this.action].nextgamer = this.next()
			gamer[this.action].prevgamer = this.prev()
			//console.log(gamer[this.action].paival.length>0&&pai.checkAttack(gamer[this.action].paival[0]))
			if(gamer[this.action].paival.length>0&&pai.checkAttack(gamer[this.action].paival[0])){//如果是攻击牌则设置下家的 nextgamer 和 prevgamer都为当前玩家  且设置下家的lose
				gamer[gamer[this.action].nextgamer].prevgamer = this.action
				gamer[gamer[this.action].nextgamer].nextgamer = this.action
				gamer[gamer[this.action].nextgamer].lastout = []
				gamer[gamer[this.action].nextgamer].paival = []

				gamer[this.action].prevgamer = this.next()
				for(var i=0;i<gamer[this.action].paival.length;i++){
					lose += pai.paiToLose(gamer[this.action].paival[i])
				}
				gamer[gamer[this.action].nextgamer].lose = lose
				banker = this.action
			}
			if(pai.allGuard(gamer[this.prev()].paival) && gamer[this.action].paival.length<1){ //如果上家出的是防守牌 
				this.action = gamer[this.action].nextgamer;
				function m_repair(){
					o.autoRepair()
				}
				this.setTimeHandle.push(setTimeout(m_repair,0))
			}else{
				if(pai.allGeneral(gamer[this.action].paival)){ //谁打出普通谁就是庄家 而且其它玩家的prevgamer都为庄家
					this.setAllPrev();
					banker = this.action
				}
				this.action = gamer[this.action].nextgamer
				if(pai.presentPai.length<1){ //玩家作弃牌处理时判断当前桌面有没有打出牌 没有牌则下家为庄
					banker = this.action
				}
				if(banker == this.action){
					function m_repair(){
						o.autoRepair()
					}
					this.setTimeHandle.push(setTimeout(m_repair,0))
				}else{
					this.main();
				}
			}
		}
	},
	next:function(){/*获取存活的下家id*/
		if(gamer[this.action].nextgamer!=undefined){
			return gamer[this.action].nextgamer
		}else{
			var act = this.action
			do{
				if(++act>=window._nums){
					act = 0
				}else{
					act = act
				}
			}while(gamer[act].life<=0)
			gamer[this.action].nextgamer = act
			return act
		}
	},
	prev:function(){/*获取存活的上家id*/
		if(gamer[this.action].prevgamer!=undefined){
			return gamer[this.action].prevgamer
		}else{
			var act = this.action
			do{
				if(--act<0){
					act = window._nums-1
				}else{
					act = act
				}
			}while(gamer[act].life<=0)
			gamer[this.action].prevgamer = act
		}
		return act
	},
	deskshow:function(){/*出牌后的桌面显示特效以及后台数据处理*/
		var index,val = gamer[this.action].lastout
		if(0==this.action){
			for(i=0;i<val.length;i++){
				$('div.pai_0').each(function(){
					if(val[i]==parseInt($(this).attr('val'))){
						$(this).remove()
					}
				})	
			}
			//$('.selected').remove()
		}else{
			for(var i=val.length-1;i>=0;i--){
				$($('.pai_'+this.action)[i]).remove()
			}	
		}
		//后台数据处理
		for(var i=0;i<val.length;i++){
			index = gamer[this.action].pai.indexOf(val[i])
			gamer[this.action].pai.splice(index,1)
			pai.temp.push(val[i]);
			pai.presentPai.push(val[i])
			var huase='';
			if(pai.getPaiHuase(val[i])<4){
				huase = '<div class="left s_paise_float"><img src="static/images/pai_'+pai.getPaiHuase(val[i])+'.png" width="20px" height="20px"></div>'
			}
			$('.outpaiarea_'+this.action).append('<div class="outpai outpai_'+this.action+'">'+show_pai[pai.valToPai(val[i])]+huase+'</div>')
		}
	},
	gamerDead:function(){
		base.dead.push(this.action)
		for(var i=0;i<gamer[this.action].pai.length;i++){
			pai.temp.push(gamer[this.action].pai[i])
		}
		//$('#gamer_'+this.action).empty()
		//$('#gamer_'+this.action).addCalss('gamerdead')
		$('#gamer_'+this.action).append('<div class="gamerdead"></div>')
		$('#gamer_'+this.action+' .gamerdead').css({left:$('#gamer_'+this.action+' .image_'+this.action+' div').offset().left,top:$('#gamer_'+this.action+' .image_'+this.action+' div').offset().top})
		$('td.result_'+this.action).html('<strong><del>阵亡</del></strong>')
		gamer[this.action].pai = []
		$('div.pai_'+this.action).each(function(){
			$(this).remove();
		})
	},
	isOver:function(){
		var ret=0;
		for(var i=0;i<window._nums;i++){
			if(gamer[i].life<=0)continue;
			ret+=1;
		}
		if(ret<=1){return true;}
		return false;
	},
	setTimeNull:function(){
		$('.time').html('')
	},
	setThisTime:function(val){
		if(!val){val='';}
		$('.time_'+this.action).html(val)
		if(-1!=val.search('15')){
			var o = this
			function m(){
				var val = parseInt($('.time_'+o.action+' strong').text())-1
				if(val<=0){
					gamer[o.action].limit-=1
					if(gamer[o.action].limit<=0){
						gamer[o.action].automode=true;
						o.changeAutoMode()
					}
					o.drop()
				}else{
					o.setThisTime('<strong>'+val+'</strong>')
				}
			}
			this.setInterHandle.push(setInterval(m,999));
		}
	},
	clearInterHandle:function(){
		for(var i=0;i<this.setInterHandle.length;i++){
			clearInterval(this.setInterHandle[i])
		}
	},
	clearTimeHandle:function(){
		for(var i=0;i<this.setInterHandle.length;i++){
			clearTimeout(this.setTimeHandle[i])
		}
	},
	clearAllHandle:function(){
		this.clearInterHandle();
		this.clearTimeHandle();
		this.setInterHandle = new Array();
		this.setTimeHandle = new Array();
	},
	showAllHandle:function(){
		try{console.log(this.setInterHandle,this.setTimeHandle)}catch(e){}
	},
	setResult:function(lose){
		$('strong#lastlife_'+this.action).text(gamer[this.action].life>0?gamer[this.action].life:0)
		$('div.result_'+this.action).width(3*gamer[this.action].life)
	},
	runReport:function(){
		++window._mark
		var outmsg = ''
		if(window._mark%100==0){
			outmsg = ' 恭喜无故障安全运行'+window._mark+'局'
		}
		try{console.log('第'+window._mark +'局 本局胜者: 玩家'+banker+outmsg)}catch(e){}
	},
	showOverAlert:function(){
		var t = this
		$('div#publicarea').append('<div class="show_over_alert"></div>')
		$('div#publicarea .show_over_alert').append('<div class="show_over_result"></div>')
		$('div.show_over_alert').css({left:$('body').width()/2-$('div.show_over_alert').width()/2,top:135})
		$('div#publicarea .show_over_alert .show_over_result').append('<div class="content"></div>')
		$('div#publicarea .show_over_alert .show_over_result').append('<div class="again_start">再来一局</div><div class="go_back"><a href="start.php">返回大厅</a></div>')
		$('div#publicarea .show_over_alert .show_over_result .again_start').click(function(){t.start();})
		
	},
	initButton:function(){
		$('div#gamer_0').append('<div class="left image_0"><div><img src="'+gamer[0].image+'" width="60" height="60"></div></div>')
		$('div#publicarea').append('<div id="action_gamer"><div class="button" id="do_out_pai">出牌</div><div class="button" id="autoanswer">提示</div><div class="button" id="pass">不出</div><div>')
		$('#gamer_0').append('<div id="automode" class="green">托管模式</div>')
		$('div#do_out_pai').click(function(){t.clickOutPai();})
		var t=this
		$('div#pass').click(function(){
			t.drop();
		})
		$('div#autoanswer').click(function(){t.autoAnswer();})
		$('div#automode').click(function(){
			if(gamer[0].automode){
				gamer[0].automode = false;
				$(this).text('托管模式')
				$(this).addClass('green')
				$(this).removeClass('red')
			}else{
				if(0==t.action){t.autoPai();}
				gamer[0].automode = true;
				t.changeAutoMode()
			}
		})
		document.getElementById("showArea").onmouseup=function(oEvent) {
			if (!oEvent) oEvent=window.event;
			if (oEvent.button==2 && 0==t.action) {
				if(gamer[0].select.length>0){
					t.clickOutPai()
				}else{
					t.alert('请先选牌')	
				}
			}
			document.getElementById("showArea").oncontextmenu=function(event) {
				if (document.all) window.event.returnValue = false;// for IE
				else event.preventDefault();
			};
		}
	},
	changeAutoMode:function(){
		$('div#automode').text('取消托管')
		$('div#automode').addClass('red')
		$('div#automode').removeClass('green')
	},
	changePaiShow:function(){
		var t = this
		for(var i=0;i<gamer[this.action].select.length;i++){
			$('div.pai_0').each(function(){
				if(gamer[t.action].select[i] == parseInt($(this).attr('val'))){
					$(this).addClass('selected')
				}
			})
		}	
	},
	alertNotice:function(){
		
	},
	alert:function(msg){
		Shake($('body')[0])
		//alert(msg)
	}
}
